import Vue from 'vue';
import VueRouter from 'vue-router';

// 注册组件 <router-view> <router-link>
Vue.use(VueRouter);

import Home from '../views/Home.vue'
import Shop from '../views/Shop.vue'
import Order from '../views/Order.vue'
import Cart from '../views/Cart.vue'
import NotFound from '../views/NotFound.vue'
import TopNav from '../views/TopNav.vue'
import TopBar from '../views/TopBar.vue'
import Layout from '../views/Layout.vue'

const router = new VueRouter({
  mode: 'history',
  // 路由表
  routes: [
    {
      path: '/a',
      redirect: {
        // name: 'Home',
        path: '/a/b/d/f/g/h/j'
      },
      component: Layout,
      children: [
        {
          path: 'b/d/f/g/h/j',
          alias: 'b',
          name: 'Home',
          component: Home
        },
      ]
    },
    {
      path: '/b',
      component: Layout,
      name: 'rb',
      children: [
        {
          path: 'd',
          name: 'TopBar',
          component: TopBar
        },
        {
          path: 'f',
          name: 'TopNav',
          component: TopNav
        },
      ]
    },
    {
      path: '/c',
      component: Layout,
      children: [
        {
          path: 'd/:id',
          component: Shop,
          // 可以同属性参数获取
          props: true
        },
        {
          path: 'b/:cid',
          component: Cart,
          // 可以同属性参数获取
          props: true
        },
      ]
    },

    {
      path: '*',
      component: NotFound,

    },
  ]
});

export default router;